Skip to main content

AddElement

Adds a paragraph or a table or a blockLvl content control using its position in the document content.

Syntax

expression.AddElement(nPos, oElement);

expression - A variable that represents a ApiDocumentContent class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nPosRequirednumberThe position where the current element will be added.
oElementRequiredDocumentElementThe document element which will be added at the current position.

Returns

This method doesn't return any data.

Example

This example adds a paragraph in document content.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let drawing = Api.CreateShape("rect", 3212465, 963295, fill, stroke);
paragraph.AddDrawing(drawing);
let docContent = drawing.GetDocContent();
docContent.RemoveAllElements();
paragraph = Api.CreateParagraph();
paragraph.AddText("We removed all elements from the shape and added a new paragraph inside it.");
docContent.AddElement(0, paragraph);